#ifndef CORE_LAMBERTIAN_H
#define CORE_LAMBERTIAN_H
#include "Material.h"
#include "Hitable.h"
#include "Utility.h"
#include "Texture.h"
namespace RayTracer
{
	 //lambertian
	class Lambertian : public Material
	{
	public:
		Lambertian(const vec3& a) : albedo(std::make_shared<SolidTexture>(a)) {}
		Lambertian(std::shared_ptr<Texture> a) : albedo(a) {}

		virtual bool Scatter(const Ray& r_in, const HitRecord& rec,
			vec3& attenuation, Ray& scattered ) const override
		{
			auto scatter_direction = rec.normal + RandomVector();
			if (CloseZore(scatter_direction))
			{
				scatter_direction = rec.normal;
			}
			scattered = Ray(rec.position, scatter_direction);
			attenuation = albedo->value(rec.u,rec.v,rec.position);
			return true;
		}

	public:
		std::shared_ptr<Texture> albedo;
	};
}
#endif // !CORE_LAMBERTIAN_H

